﻿@using Chaine
@model Chaine.Models.EventModels
@{
    ViewBag.Title = "Create new event";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section maincontent{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/js/ckeditor/ckeditor.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $().ready(function () {
            CKEDITOR.replace("Content");
            var dates = $("#StartDate,#EndDate").datepicker({
                numberOfMonths: 3,
                onSelect: function (selectedDate) {
                    var option = this.id == "StartDate" ? "minDate" : "maxDate",
					instance = $(this).data("datepicker"),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
                    dates.not(this).datepicker("option", option, date);

                }
            });
        });
    </script>
    @using (Html.BeginForm("create", "AdminEvent", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary(true)
        <div class="form-horizontal">
            <fieldset>
                <legend>@ViewBag.Title</legend>
                <div class="control-group @(ViewData.ModelState["Title"].ErrorClass("error"))">
                    <label class="control-label">
                        Title</label>
                    <div class="controls">
                        @Html.EditorFor(m => m.Title)
                        @Html.ValidationMessageFor(m => m.Title, null, new { @class = "help-inline" })
                    </div>
                </div>
                <div class="control-group @(ViewData.ModelState["Location"].ErrorClass("error"))">
                    <label class="control-label">
                        Location</label>
                    <div class="controls">
                        @Html.EditorFor(m => m.Location)
                        @Html.ValidationMessageFor(m => m.Location, null, new { @class = "help-inline" })
                    </div>
                </div>
                <div class="control-group @(ViewData.ModelState["Price"].ErrorClass("error"))">
                    <label class="control-label">
                        Price</label>
                    <div class="controls">
                        @Html.EditorFor(m => m.Price)
                        @Html.ValidationMessageFor(m => m.Price, null, new { @class = "help-inline" })
                    </div>
                </div>
                <div class="control-group @(ViewData.ModelState["StartDate"].ErrorClass("error"))  @(ViewData.ModelState["StartHour"].ErrorClass("error"))  @(ViewData.ModelState["StartMin"].ErrorClass("error"))">
                    <label class="control-label">
                        Start DateTime</label>
                    <div class="controls">
                        @Html.TextBoxFor(m => m.StartDate, new { @class = "span1", style = "width:70px;" })
                        @Html.DropDownListFor(m => m.StartHour, Chaine.Util.HoursList().ToSelectListItem(), new { @class = "span1" })
                        :
                        @Html.DropDownListFor(m => m.StartMin, Chaine.Util.MinutesList().ToSelectListItem(), new { @class = "span1" })
                        @Html.ValidationMessageFor(m => m.StartDate, null, new { @class = "help-inline" })
                    </div>
                </div>
                <div class="control-group @(ViewData.ModelState["EndDate"].ErrorClass("error"))  @(ViewData.ModelState["EndHour"].ErrorClass("error")) @(ViewData.ModelState["EndMin"].ErrorClass("error"))">
                    <label class="control-label">
                        End DateTime</label>
                    <div class="controls">
                        @Html.TextBoxFor(m => m.EndDate, new { @class = "span1", style = "width:70px;" })
                        @Html.DropDownListFor(m => m.EndHour, Chaine.Util.HoursList().ToSelectListItem(), new { @class = "span1" })
                        :
                        @Html.DropDownListFor(m => m.EndMin, Chaine.Util.MinutesList().ToSelectListItem(), new { @class = "span1" })
                        @Html.ValidationMessageFor(m => m.EndDate, null, new { @class = "help-inline" })
                    </div>
                </div>
                <div class="control-group @(ViewData.ModelState["Poster"].ErrorClass("error"))">
                    <label class="control-label">
                        Poster</label>
                    <div class="controls">
                        <input name="file" id="poster" type="file" />
                        @Html.ValidationMessageFor(m => m.Poster, null, new { @class = "help-inline" })
                        <p class="help-block">
                            PNG, JPG, JPEG is allowed.</p>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">
                        Content</label>
                    <div class="controls">
                        @Html.TextAreaFor(m => m.Content, new { id = "Content", name = "Content" })
                    </div>
                </div>
                <div class="form-actions">
                    <input type="submit" value="Save" class="btn btn-primary btn-large" />
                    @Html.ActionLink("Cancel", "index", "AdminEvent", new { @class = "btn btn-large" })
                </div>
            </fieldset>
        </div>
    }
}
@section sidebar{
    @Html.Partial("~/views/shared/_adminsidebar.cshtml")
}
